package com.sykj.bsc.cl.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sykj.bsc.cl.bean.Bis_shop_collect;
import com.sykj.bsc.hyx.service.Bis_opinionService;
import com.sykj.bsc.jhy.entity.Bis_bag_record;
import com.sykj.bsc.jhy.entity.Bis_business_order;
import com.sykj.bsc.jhy.entity.Bis_nurse_bag;
import com.sykj.bsc.jhy.entity.Bis_project_record;
import com.sykj.bsc.jhy.service.serviceImpl.Bis_nurse_projectServiceImpl;
import com.sykj.bsc.wsy.service.Bis_beauty_configService;
import com.sykj.bsc.zjj.bean.Bis_custom_user;
import com.sykj.bsc.zjj.service.Bis_shop_userService;
import com.sykj.bsc.zn.bean.Bis_shop;
import com.sykj.bsc.zn.service.znServiceImpl;
/**
 * 二级菜单
 * @author Lenovo
 *
 */
@Controller
@RequestMapping("wechat")
public class BagController {
	//胡颖箫hyx
	@Autowired
	public Bis_opinionService bis_opinionService;
	//王舒雅 wsy
	@Autowired
	Bis_beauty_configService service;
	//张俊杰 zjj
	@Autowired
	private Bis_shop_userService bsus;
	//江海阳 jhy
	@Autowired 
	Bis_nurse_projectServiceImpl impl;
	//张诺 zn
	@Autowired
	znServiceImpl sus;
	/**
	 * 找礼包
	 * @param model
	 * @return
	 */
	//用来显示找礼包的平台
	@RequestMapping("/Gobag")
	@ResponseBody
	public List<Bis_nurse_bag> GoBag(Model model){
		List<Bis_nurse_bag> list=impl.selectBis_nurse_bag();
		/*model.addAttribute("list", list);*/
		return list;
	}
	/**
	 * 我的大礼包
	 * @param model
	 * @return
	 */
	//用来显示微信平台进入我的大礼包
	@RequestMapping("/GomyBag")
	public String GomyBag(Model model){
		List<Bis_nurse_bag> list=impl.selectBis_nurse_bag();
		model.addAttribute("list", list);
		return "/backstage/cl/wechat/bag/myBag";
	}
	//用来显示我的礼包的平台
	@RequestMapping("/Gobag1")
	@ResponseBody
	public List<Bis_bag_record> GoBag1(Model model,HttpSession session){
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		String custom_user_id=ss.getCustom_user_id();
		List<Bis_bag_record> list =impl.selectBis_bag_record(custom_user_id);
		return list;
	}	
	
	/**
	 * 我的已拆礼包
	 * @param model
	 * @return
	 */
	//用来显示微信平台进入我的已拆礼包
	@RequestMapping("/GomyProject")
	public String GomyProject(Model model){
		return "/backstage/cl/wechat/project/myProject";
	}
	//用来显示微信平台我的礼包详情
	@RequestMapping("/GoProject")
	@ResponseBody
	public List<Bis_bag_record> GoProject(Model model,HttpSession session){
		System.out.println("---------------------------------");
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		String custom_user_id=ss.getCustom_user_id();
		List<Bis_bag_record> bis_project_record=impl.selectBis_bag_record(custom_user_id);
		return bis_project_record;
	}
	
	/**
	 * 我的订单
	 * @return
	 */
	//用来显示微信平台进入我的订单
	@RequestMapping("/GomyOrder")
	public String GomyOrder(){
		return "/backstage/cl/wechat/my/order/myOrder";
	}
	//用来显示微信平台进入我的订单
	@RequestMapping("/GoOrder")
	@ResponseBody
	public List<Bis_business_order> GoOrder(HttpSession session){
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		Map<String, Object> map=new HashMap<>();
		map.put("custom_user_id", ss.getCustom_user_id());
		List<Bis_business_order> bis_business_order=impl.selectBis_business_order(map);
		for (Bis_business_order a : bis_business_order) {
			System.out.println(a.getCustom_user_id()+":"+a.getBis_shop().getShop_name());
		}
		return bis_business_order;
	}
	
	
	/**
	 * 颜值
	 * @param model
	 * @param session
	 * @return
	 */
	//用来显示微信平台进入我的颜值
	@RequestMapping("/GomyBeauty")
	public String GomyBeauty(Model model,HttpSession session){
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		Map<String, Object> map=new HashMap<>();
		map.put("custom_user_id", ss.getCustom_user_id());
		Bis_custom_user bis_custom_user=bsus.getMobileBis_custom_user(map);
		model.addAttribute("bis_custom_user", bis_custom_user);
		return "/backstage/cl/wechat/my/myBeauty";
	}
	/**
	 * 我的收藏
	 * @return
	 */
	//用来显示微信平台进入我的收藏
	@RequestMapping("/GomyShopCollect")
	public String GomyShopCollect(Model model,HttpSession session){
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		String custom_user_id=ss.getCustom_user_id();
		String show_data="";
		List<Bis_shop_collect> bis_shop_collect=service.selectBis_shop_collect(custom_user_id);
		if (bis_shop_collect.size()!=0) {
			show_data="1";
		}else{
			show_data="0";
		}
		model.addAttribute("bis_shop_collect", bis_shop_collect);
		model.addAttribute("show_data", show_data);
		return "/backstage/cl/wechat/my/myShopCollect";
	}
	//我的收藏跳转到店铺详情
	@RequestMapping("/GoshowShopDetail1")
	public String GoshowShopDetail1(Model model,@RequestParam(value="shop_id")String shop_id){
		Bis_shop bis_shop= sus.getBis_shopByid(shop_id);
		Map<String, Object> map=new HashMap<>();
		map.put("shop_id", shop_id);
		List<Bis_project_record> bis_project_records=impl.selectBis_project_record(map);
		model.addAttribute("bis_project_records", bis_project_records);
		model.addAttribute("bis_shop", bis_shop);
		return "/backstage/cl/wechat/shop/showShopDetail";
	}
	
	/**
	 * 意见反馈
	 * @return
	 */
	//用来显示微信平台进入意见反馈
	@RequestMapping("/Gofeedback")
	public String Gofeedback(){
			
		return "/backstage/cl/wechat/my/feedback";
	}
	//用来意见反馈
	@RequestMapping("/Gofeed")
	@ResponseBody
	public String Gofeed(@RequestParam(value="content")String content,HttpSession session){
		Bis_custom_user ss=(Bis_custom_user) session.getAttribute("user");
		Map<String, Object> map=new HashMap<>();
		map.put("custom_user_id", ss.getCustom_user_id());
		map.put("content", content);
		this.bis_opinionService.saveBis_opinion(map);
		return "1";
	}
}
